package com.ecarx.camera.constant;

import android.util.SparseIntArray;

import com.ecarx.camera.R;
import com.ecarx.camera.worker.event.DvrEvent;

/**
 * Dvr错误状态描述信息常量定义
 */
public class DvrStateDesc {

    /**
     * Dvr错误状态描述信息Map
     */
    private static final SparseIntArray DVR_STATE_MESSAGE_MAP = new SparseIntArray();

    static {
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_CAMERA_CONNECTION_LOST, R.string.camera_error_desc);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_VIDEO_RECORD_FAILURE, R.string.camera_error_desc);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_MEMORY_READ_ERROR, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_MEMORY_WRITE_ERROR, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_SYSTEM_ERROR, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_OVER_HEAT, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_RESOURCE_OCCUPIED, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_VOLTAGE_ABNORMAL, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_EMMC_STATUS_ERROR, R.string.message_system_error);
        DVR_STATE_MESSAGE_MAP.put(DvrEvent.DvrErrorState.DVR_STATE_UNKNOWN_ERROR, R.string.message_system_error);
    }

    /**
     * 获取Dvr状态对应的字符串ResourceId
     * @param errorState
     * @return
     */
    public static int getDvrStateStringResId(@DvrEvent.DvrErrorState int errorState) {
        return DVR_STATE_MESSAGE_MAP.get(errorState, R.string.camera_error_desc);
    }
}
